package com.hzbat.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hzbat.entity.IbmsOS;
import com.hzbat.entity.RegisterHost;
import com.hzbat.entity.WorkerHost;
import com.hzbat.response.DataResponse;
import com.hzbat.service.RegisterNodeConfiguereService;

@Controller
@RequestMapping("registerNode")
public class RegisterNodeController {

	@Autowired
	RegisterNodeConfiguereService registerNodeConfiguereServiceImpl;
	
	
	
	/***
	 * 跳转到注册节点页面
	 * @param model
	 * @return
	 */
	@RequestMapping("getNodesConfiguere")
	public String getNodesConfiguere(Model model){
		return "cluster/nodes";
	}
	
	/**
	 * 获取ibmsOS信息
	 * @param ibmsOS
	 * @return
	 */
	@ResponseBody
	@RequestMapping("getOsTypesList")
	public DataResponse<List<IbmsOS>> getOsTypesList(IbmsOS ibmsOS){
		DataResponse<List<IbmsOS>> response = new DataResponse<List<IbmsOS>>();
		response.setData(registerNodeConfiguereServiceImpl.getIbmsOSList(ibmsOS));
		return response ;
	}
	
	/**
	 * 获取注册中心主机列表
	 * @param registerHost
	 * @return
	 */
	@ResponseBody
	@RequestMapping("getHostsList")	
	public DataResponse<List<RegisterHost>> getHostsList(RegisterHost registerHost){
		DataResponse<List<RegisterHost>> response = new DataResponse<List<RegisterHost>>();
		response.setData(registerNodeConfiguereServiceImpl.getRegisterHostList(registerHost));
		return response ;		
	}
	
	/**
	 * 获取计算节点进程列表
	 * @param workerHost
	 * @return
	 */
	@ResponseBody
	@RequestMapping("getWorkersList")	
	public DataResponse<List<WorkerHost>> getWorkersList(WorkerHost workerHost){
		DataResponse<List<WorkerHost>> response = new DataResponse<List<WorkerHost>>();
		response.setData(registerNodeConfiguereServiceImpl.getWorkerHostList(workerHost));
		return response ;
	}
	
}
